<?php
/**
 * User: zwh
 * Time: 2016-10-24 15:56:56
 */

class MirrorOrderProductNonStandard extends Eloquent
{
    protected $table = "mirror_order_product_non_standard";
    
    /**
     * @Author:      zwh
     * @DateTime:    2016-10-25 15:55:20
     * @Description: 用于修改 非标产品的 产品数量
     */
    public static function changeProductItemNum($order_id,$opns_old,$number,$amount){
        return DB::transaction(function () use ($order_id,$opns_old,$number,$amount) {
            $opns=MirrorOrderProductNonStandard::find($opns_old->id);
            $opns->num=$number;
            $opns->amount=$amount;
            $opns->save();
    
            //订单应付金额及优惠信息将重新计算，废弃原有再优惠信息上加减
            MirrorOrders::calculate($order_id);
            return array('code' => 0, 'msg' => 'ok', 'result' => array("order_id"=>$order_id));
        });
    }
}
